package com.jingogo.service.impl;

import com.jingogo.common.BusinessException;
import com.jingogo.entity.Store;
import com.jingogo.mapper.StoreMapper;
import com.jingogo.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    private StoreMapper storeMapper;

    @Override
    public void addStore(Store store) {
        if (store.getName() == null) throw new BusinessException("门店名称不能为空");
        storeMapper.insert(store);
    }

    @Override
    public void editStore(Store store) {
        if (store.getId() == null) throw new BusinessException("门店ID不能为空");
        storeMapper.update(store);
    }

    @Override
    public void deleteStore(Long storeId) {
        storeMapper.deleteById(storeId);
    }

    @Override
    public List<Store> listStores() {
        return storeMapper.selectAll();
    }
} 